package tam;

import static org.junit.Assert.assertEquals;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.testing.RobotTestBed;

/**
 * Tests that Ringer wins 10 rounds against Crazy.
 * @author Micah
 *
 */
public class TestRingerVersusCrazy extends RobotTestBed {

  /**
   * Specifies that Crazy and Ringer are to be matched up in this test case.
   *
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.Crazy,tam.Ringer";
  }
  
  /**
   * This test runs for 10 rounds.
   *
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * On battle completion, check that all rounds were won.
   * 
   * @param event Info about the current state of the battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    // Return the results in order of getRobotNames.
    BattleResults[] battleResults = event.getIndexedResults();
    // Sanity check that results[1] is Ringer (not strictly necessary, but illustrative).
    BattleResults Ringer = battleResults[1];
    String robotName = Ringer.getTeamLeaderName();
    assertEquals("Check that results[1] is Ringer", robotName, "tam.Ringer*");
    
    // Check to make sure Ringer won all rounds.
    assertEquals("Check Ringer winner", Ringer.getFirsts(), getNumRounds());
  }

}
